package com.xy.biz.rs.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.rs.domain.req.*;
import com.xy.biz.rs.domain.resp.GetRecordTemplateUserGroupResponse;
import com.xy.tool.util.BeanUtilsEx;
import com.xy.biz.rs.domain.bo.RecordTemplateBO;
import com.xy.biz.rs.domain.po.RecordTemplatePO;
import com.xy.biz.rs.domain.query.RecordTemplateQuery;
import com.xy.biz.rs.domain.resp.GetRecordTemplateResponse;

/**
 *
 *
 * @author wwj
 * @date 2021-4-9
 */
public class RecordTemplateConverter {

	public static RecordTemplatePO toPO(RecordTemplateBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplatePO(), true);
	}

	public static List<RecordTemplatePO> toPO(Collection<RecordTemplateBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplatePO(), true);
	}

	public static RecordTemplateBO fromPO(RecordTemplatePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateBO());
	}

	public static List<RecordTemplateBO> fromPO(Collection<RecordTemplatePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplateBO());
	}

	public static RecordTemplateBO toBO(SaveRecordTemplateRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateBO(), true);
	}

	public static RecordTemplateBO toBO(AppointUpdaterRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateBO(), true);
	}

	public static RecordTemplateBO toBO(UpdateRecordTemplateStatusRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateBO(), true);
	}

	public static RecordTemplateBO toBO(UpdateRecordTemplateRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new RecordTemplateBO(), true);
	}

	public static List<RecordTemplateBO> toBO(Collection<SaveRecordTemplateRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new RecordTemplateBO(), true);
	}

	public static GetRecordTemplateResponse toResponse(RecordTemplateBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetRecordTemplateResponse(),
				(src,tar)->tar.setGetRecordTemplateUserGroupResponseList(BeanUtilsEx.copyPropertiesForNewList(src.getGetRecordTemplateUserGroupBOS(),()->new GetRecordTemplateUserGroupResponse())));
	}

	public static List<GetRecordTemplateResponse> toResponse(Collection<RecordTemplateBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetRecordTemplateResponse());
	}

	public static RecordTemplateQuery toQuery(ListRecordTemplateRequest source) {
		if(null == source) {
			return null;
		}
		RecordTemplateQuery target = new RecordTemplateQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
